package batframework.mvc.action;

import java.io.File;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;



public class UrlMapping
{
	private String path;
	
	private String method;
	
	private String[] pattern;
	
	public UrlMapping(String path,String method)
	{
		this.path = path;
		this.method = method;
		if(path.length() > 0)
			path += "/";
		pattern = path.split("/");
	}

	public UrlMapping()
	{
		
	}
	
	

	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = 1;
		result = prime * result + ((method == null) ? 0 : method.hashCode());
		result = prime * result + ((path == null) ? 0 : path.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj)
	{
		if(obj != null)
		{
			final UrlMapping mapping = (UrlMapping) obj;
			if(!mapping.getMethod().equals(this.method))
				return false;
			if(!mapping.getPath().equals(this.path))
				return false;
		}
		return true;
	}

	public String[] getPattern()
	{
		return this.pattern;
	}
	
	public void setPattern(String[] pattern)
	{
		this.pattern = pattern;
	}

	public String getPath()
	{
		return path;
	}

	public void setPath(String path)
	{
		this.path = path;
	}

	public String getMethod()
	{
		return method;
	}

	public void setMethod(String method)
	{
		this.method = method;
	}
	
	public boolean match(UrlMapping urlMapping)
	{
		// TODO Auto-generated method stub
		return true;
	}
	
	public static void main(String[] args) throws Exception
	{
		while(true){
			long s1 = System.currentTimeMillis();
			Path path = Paths.get("H:\\framework\\w");
			File file = path.toFile();
			System.out.println(file.exists());
			long s2 = System.currentTimeMillis();
			System.out.println(s2 -s1);
			Thread.sleep(100);
		}
	}
}
